/*
 * Copyright (c) 2015 sb Jung.
 * All right reserved.
 */
package kr.co.j2b.api.sample.service;

import java.util.List;
import java.util.Map;

import kr.co.j2b.api.sample.dao.SampleDao;
import kr.co.j2b.common.MyBatisAbstractSqlSession;
import kr.co.j2b.common.model.ResultCode;
import kr.co.j2b.common.model.ResultResponse;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
 * <pre>
 * kr.co.j2b.api.sample.service 
 *    |_ SampleServiceImpl.java
 * </pre>
 * @date : 2015. 4. 7. 오후 1:43:36
 * @author : J-PC
 */
@Service
public class SampleServiceImpl implements SampleService {
	private Log log = LogFactory.getLog(getClass());
	
	@Autowired(required=true)
	public SampleDao sampleDao;
	
	@Override
	public ResultResponse getList(){
		log.info("SampleServiceImpl - getList");
		ResultResponse result = new ResultResponse();
		ResultCode code = new ResultCode();
		code.setCode("200");
		code.setMessage("OK");
				
		result.setHeader(code);		
		return result;
	}
	
	@Override
	public List<Map<String, Object>> getCountries(){
		log.info("SampleServiceImpl - getCountries");
		
		
		/**
		 * DBConnection DataSource
		 */
		((MyBatisAbstractSqlSession) sampleDao).getSqlSession("sqlSessionMysql01");
		
		return sampleDao.getCountries();		
	}
	
	@Override
	public Map<String, Object> getCountriesDetail(String id){
		log.info("SampleServiceImpl - getCountriesDetail");
		
		
		/**
		 * DBConnection DataSource
		 */
		((MyBatisAbstractSqlSession) sampleDao).getSqlSession("sqlSessionMysql01");
		
		return sampleDao.getCountriesDetail(id);		
	}
}
